package com.lanou3g.code0416;

import java.io.*;

/**
 * Created by dllo on 18/4/16.
 */
public class Test04 {
    public static void main(String[] args)  {

        // save();
           load();

    }

    private static void load(){


        FileInputStream fis = null;
        ObjectInputStream ois = null;

        try {
             fis = new FileInputStream("p");
             ois = new ObjectInputStream(fis);
             Person p = (Person) ois.readObject();
            System.out.println(p.getName());


        } catch (Exception e) {
            e.printStackTrace();
        }
    }



    private static void save()  {
        FileOutputStream fos = null;
        ObjectOutputStream oos = null;

        Person p = new Person("idfs","jsdfsdf");


        try {
            fos = new FileOutputStream("p");
            oos = new ObjectOutputStream(fos);
            oos.writeObject(p);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
